{# **
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to https://devdocs.prestashop.com/ for more information.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * #}

<table class="table" data-role="history-grid-table">
  <tbody>
    {% for status in orderForViewing.history.statuses %}
    <tr>
      <td data-role="status-column">
        <span class="badge rounded badge-print-light"
              style="background-color: {{ status.color }}; color: {{ is_color_bright(status.color) ? 'black' : 'white' }};"
        >
          {{ status.name }}
        </span>
      </td>
      <td class="text-right" data-role="employee-column">
        {% if status.employeeLastName is not empty %}
          {{ status.employeeFirstName ~ ' ' ~ status.employeeLastName }}
        {% endif %}
        {% if status.apiClientId is not empty %}
          {{ 'Api Client: %api_client_id%'|trans({'%api_client_id%': status.apiClientId}, 'Admin.Global') }}
        {% endif %}
      </td>
      <td class="text-right" data-role="date-column">
        {{ status.createdAt|date_format_full }}
      </td>
      <td class="text-right">
        {% if status.withEmail %}
          <form method="post"
                action="{{ path('admin_orders_resend_email', {orderId: orderForViewing.id, orderHistoryId: status.orderHistoryId, orderStatusId: status.orderStatusId}) }}">
            <button class="btn btn-primary btn-sm">
              {{ 'Resend email'|trans({}, 'Admin.Orderscustomers.Feature') }}
            </button>
          </form>
        {% endif %}
      </td>
    </tr>
    {% endfor %}
  </tbody>
</table>

<div class="d-flex justify-content-end">
  {{ form_start(updateOrderStatusForm, {action: path('admin_orders_update_status', {orderId: orderForViewing.id}), attr: {class: 'card-details-form'}}) }}
    <div class="form-group card-details-actions">
      {{ form_widget(updateOrderStatusForm.new_order_status_id) }}

      <button class="btn btn-primary update-status mt-3 mt-md-0 ml-0 ml-md-3">
        {{ 'Update status'|trans({}, 'Admin.Orderscustomers.Feature') }}
      </button>
    </div>

    <div class="d-none">
      {{ form_rest(updateOrderStatusForm) }}
    </div>
  {{ form_end(updateOrderStatusForm) }}
</div>

{{ include('@PrestaShop/Admin/Sell/Order/Order/Blocks/View/internal_note.html.twig') }}
